var loginUsername = '198504203'; // "${loginUsername}"; //获得当前登录人员的userName
var taskUid = '3541874';

// @Bind view.onReady
!function(self, arg) {
	var dsCheckTask = view.id("dsCheckTask");
	dsCheckTask.set("parameter", {
		"taskUid" : taskUid
	});
	dsCheckTask.flush();
	
	var checkTask = dsCheckTask.getData("#");
	if(checkTask){
		var dsCheckBill = view.id("dsCheckBill");
		dsCheckBill.set("parameter", {
			"checkTaskUid" : checkTask.get("uuid")
		});
		dsCheckBill.flush();
	}
}

//@Bind #dtCheckBill.onInsert
!function(self,arg,dsCheckTaskAssign) {
	var assn = dsCheckTaskAssign.getData('#');
	var bill = arg.entity;
	bill.set("checkTaskUid", assn.get("checkTaskUid"));
	bill.set("taskUid", assn.get("checkTask.taskUid"));
	bill.set("checkBillState", 0);
	bill.set("checkType", assn.get("checkTask.checkTaskType"));
	bill.set("checkTypeDesc", assn.get("checkTaskTypeDesc"));
	bill.set("checkTask.operationTask.model", assn.get("checkTask.operationTask.model"));
	bill.set("checkTask.operationTask.part.drawingId", assn.get("checkTask.operationTask.part.drawingId"));
	bill.set("checkTask.operationTask.part.partName", assn.get("checkTask.operationTask.part.partName"));
	bill.set("checkTask.operationTask.batchNum", assn.get("checkTask.operationTask.batchNum"));
	bill.set("checkTask.operationTask.operationIdDesc", assn.get("checkTask.operationTask.operationIdDesc"));
	bill.set("checkTask.operationTask.taskName", assn.get("checkTask.operationTask.taskName"));
	bill.set("checkTask.operationTask.planQty", assn.get("checkTask.operationTask.planQty"));
	bill.set("submitQty", assn.get("checkTask.operationTask.planQty"));
	bill.set("actualCheckQty", assn.get("checkTask.operationTask.planQty"));
	bill.set("defectQty", 0);
//	bill.set("checkCount", 1);
	bill.set("defectQtyBeforeCheck", 0);
	bill.set("keyCount", 0);
	bill.set("isStatistic", false);
	bill.set("createTime", new Date());
}

//@Bind #btnGenerateDetail.onClick
!function(self,arg,actionGenerateDetail,dsCheckBill,dsCheckTaskAssign) {
	var checkBill = dsCheckBill.getData('#');
	var assn = dsCheckTaskAssign.getData('#');
	
	actionGenerateDetail.set("parameter", 
			{"checkBillUid" : checkBill.get("uuid"),
		     "operationTaskUid" : assn.get("checkTask.taskUid")});
	actionGenerateDetail.execute();
}


//@Bind #actionGenerateDetail.onSuccess
!function(self,arg,dsCheckTask,dsCheckBill) {
	dsCheckBill.flush();
}

